#! /bin/bash
#
#  This file is part of the Jikes RVM project (http://jikesrvm.org).
#
#  This file is licensed to You under the Eclipse Public License (EPL);
#  You may not use this file except in compliance with the License. You
#  may obtain a copy of the License at
#
#      http://www.opensource.org/licenses/eclipse-1.0.php
#
#  See the COPYRIGHT.txt file distributed with this work for information
#  regarding copyright ownership.
#

#
# Usage: RunSPECmark [spec output file]
#
OUTPUT_FILE=$1
echo -e "\t\tBest Run"
product="1.00"
for code in compress jess db javac mpegaudio mtrt jack
do
   fgrep -v "NOT VALID" $OUTPUT_FILE | fgrep Finished | fgrep $code > tmp
   time=`$RVM_ROOT/testing/tests/SPECjvm98/parse_spec`
   reference=`fgrep $code $RVM_ROOT/testing/tests/SPECjvm98/specmark.reference| sed -e 's/[a-zA-A]//g'`
   ratio=`perl -e 'printf("%1.2f",@ARGV[0]/@ARGV[1])' $reference $time`
   perl -e 'printf("%10s    Time:%10s    Ratio:%10s\n",$ARGV[0],$ARGV[1],$ARGV[2])' $code $time $ratio
   product=`perl -e 'printf("%1.2f",@ARGV[0]*@ARGV[1])' $product $ratio`
   rm -f tmp
done
one_seventh=0.1428571428571
geo_mean=`perl -e 'printf("%1.2f",@ARGV[0]**@ARGV[1])' $product $one_seventh`
perl -e 'printf("Bottom Line: Result: %10s\n",@ARGV[0])' $geo_mean

echo -e "\n\t\tFirst Run"
product="1.00"
for code in compress jess db javac mpegaudio mtrt jack
do
   fgrep -v "NOT VALID" $OUTPUT_FILE | fgrep Finished | fgrep $code > tmp
   time=`$RVM_ROOT/testing/tests/SPECjvm98/parse_spec_min`
   reference=`fgrep $code $RVM_ROOT/testing/tests/SPECjvm98/specmark.reference| sed -e 's/[a-zA-A]//g'`
   ratio=`perl -e 'printf("%1.2f",@ARGV[0]/@ARGV[1])' $reference $time`
   perl -e 'printf("%10s    Time:%10s    Ratio:%10s\n",$ARGV[0],$ARGV[1],$ARGV[2])' $code $time $ratio
   product=`perl -e 'printf("%1.2f",@ARGV[0]*@ARGV[1])' $product $ratio`
   rm -f tmp
done
one_seventh=0.1428571428571
geo_mean=`perl -e 'printf("%1.2f",@ARGV[0]**@ARGV[1])' $product $one_seventh`
perl -e 'printf("First Run Result: %10s\n",@ARGV[0])' $geo_mean
